package com.xrui.ftp;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Interface representing the subset of org.apache.commons.net.ftp.FTPClient we use,
 * pulled out to facilitate testing/mocking/stubbing of the FTP helper classes. Not
 * intended for direct use by application code, hence nonpublic.
 *
 * It shouldn't modify any method signatures, or add any functional value e.g. retry,
 * autoconnect etc - those belong at a higher level.
 */
interface FtpClient {

    // Lifecycle
    //
    void connect(String hostname) throws IOException;
    boolean login(String username, String password) throws IOException;
    boolean logout() throws IOException;
    void disconnect() throws IOException;

    // Configuration
    //
    void enterLocalActiveMode();
    void enterLocalPassiveMode();
    boolean setFileType(int fileType) throws IOException;
    boolean changeWorkingDirectory(String pathname) throws IOException;

    // Operations
    //
    String[] listNames() throws IOException;
    @SuppressWarnings("BooleanMethodIsAlwaysInverted") // because "failedToRetrieveFile" would be silly
    boolean retrieveFile(String remoteFileName, OutputStream outputStream) throws IOException;

    // Inspection
    //
    boolean isConnected();
    int getReplyCode();
    String getReplyString();
}
